package fun.coding.design.pattern;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class LowerCaseInputStreamTest {

    public static void main(String[] args) {
        int c;
        
        InputStream in = null;
        try {
            in = new LowerCaseInputStream(new BufferedInputStream(new FileInputStream("/Users/xiaoyushi/workspace/brain-code-jam/bin/fun/coding/design/pattern/test.txt")));
            
            while ((c = in.read()) >= 0) {
                System.out.print(String.format("Int value is %d and char value is %c", c, (char)c));
            }
            
            // Should be put in finally but can't.
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // This is kinda of stupid that in.close could also throw exception!
            // No, java has try with resources!!
            // try (InputStream is = new BufferInputStream) and it will be closed because it implements the AutoCloseable. 
            // in.close();
        }
    }

}
